#ifndef F_CAHUMSAT_PlannerC_h
#define F_CAHUMSAT_PlannerC_h

// ***********************************************************************

// class EDROOMTopContext

// ***********************************************************************



class EDROOMTopContext {

protected:

enum EDROOMCAHUMSAT_PlannerSignal { EDROOMSignalTimeout, EDROOMSignalDestroy, SToListening, SToStandBy, SKeepOnComm, STMToTransmit, SToComm, SInStandBy, STMTransmited, SCommConfigured, STCReceived, SCommInterrupted, SHouseKStatus, SSSIStarted, SSGIStarted, SToEmergency, SStartSGIComm, SEndSGIComm, SStartSSIComm, SEndSSIComm };


	friend class CAHUMSAT_Planner;

	CAHUMSAT_Planner &EDROOMcomponent;

	CEDROOMMessage * &Msg;

	CEDROOMMessage * &MsgBack;

	//Ports

	CEDROOMInterface & SSICtrl;
	CEDROOMInterface & PlannerSGIControl;
	CEDROOMInterface & PlannerHousek;
	CEDROOMTimingInterface & Timer;

	enum edroomStateId{I, Ready};

	enum IdTrans{Init, Timeout, Timeout_StartSSI, Timeout_NoCommProg, Timeout_StartSGI, Timeout_EndSSI, Timeout_EndSGI, CommInterrupted, CommInterrupted_SGIActive, CommInterrupted_EndComm,  EDROOMMEMORIA };

	//Constantes



	//Variables

	bool &VSGIActive;
	bool &VSGIEnd;
	bool &VSSIActive;
	bool &VSSIEnd;


	//Pool

	class CEDROOMPOOLCDDataBurst:public CEDROOMProtectedMemoryPool {
		public:
		CEDROOMPOOLCDDataBurst(TEDROOMUInt32 elemCount,CDDataBurst *pMem, TEDROOMBool *pMarks);
		CDDataBurst	* AllocData();
	};
	CEDROOMPOOLCDDataBurst	& CEDROOMPoolCDCommConfig;


	// CONSTRUCTORES

	EDROOMTopContext (CAHUMSAT_Planner &act, bool & EDROOMpVarVSGIActive, bool & EDROOMpVarVSGIEnd, bool & EDROOMpVarVSSIActive, bool & EDROOMpVarVSSIEnd, CEDROOMPOOLCDDataBurst & EDROOMpPoolCDDataBurst );

	EDROOMTopContext ( EDROOMTopContext &contex );

public:

	bool EDROOMSearchContextTrans(TEDROOMTransId &edroomCurrentTrans);

	void EDROOMNuevoMens () { EDROOMcomponent.EDROOMNewMsg(); }

	// Funciones Definidas por el usuario

	void	FCommProg();

	void	FEndComm();

	void	FIni();

	void	FKeepOnComm();

	void	FProgSwWatchDog();

	void	FSGIEnd();

	void	FSGIStart();

	void	FSSIEnd();

	void	FSSIStart();

	TEDROOMBool	GEndSGI();

	TEDROOMBool	GEndSSI();

	TEDROOMBool	GStartSGI();

	TEDROOMBool	GStartSSI();

};

// ***********************************************************************

// class EDROOMTopState

// ***********************************************************************



class EDROOMTopState : public EDROOMTopContext {

protected:



	EDROOMTopContext::edroomStateId edroomCurrentState;

	EDROOMTopContext::edroomStateId edroomNextState;

	//Variables

	bool VSGIActive;
	bool VSGIEnd;
	bool VSSIActive;
	bool VSSIEnd;


	//Pools

	CEDROOMPOOLCDDataBurst	CEDROOMPoolCDCommConfig;


public:

	// CONSTRUCTOR

	EDROOMTopState (CAHUMSAT_Planner &act, CEDROOMMemory *pEDROOMMemory  );


	// EDROOMBehaviour**********************************************

	void EDROOMBehaviour();

	// Inicio**********************************************

	void EDROOMInicio();

	// ***********************************************************************

	// SubEstado Inicial 

	// ***********************************************************************



	TEDROOMTransId EDROOMIllegada();

	// ***********************************************************************

	// SubEstado Hoja Ready

	// ***********************************************************************



	TEDROOMTransId EDROOMReadyllegada();

};


#endif
